{extend name="base/main" /}
{block name="body"}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>子类数据页面修改操作</h5>
        </div>
        <div class="ibox-content">
            <form id="f" action="{:url('Classification/modifyedit')}" class="form-horizontal m-t">
                <div class="form-group">
                    <label class="layui-form-label">父级分类</label>
                    <div class="layui-input-block">
                        <select name="classification_name" lay-filter="aihao">
                            <option value="">请选择</option>
                            {foreach $data as $k => $v}
                            <option value="{$v.id}" <?php if($v['id']==$find['classification_name_id']){ echo "selected"; } ?>> {$v.classification_name}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">分类名称</label>
                    <div class="col-sm-4">
                        <input name="subclass_name" value="{$find.subclass_name}" class="form-control" type="text" datatype="*2-15" errormsg="角色名称范围在2~15位之间">

                    </div>
                </div>
                <div class="form-group">
                    <div class="layui-upload">
                        <label class="col-sm-2 control-label">图标：</label>
                        <div class="col-sm-4">
                            <button type="button" class="layui-btn" id="test2">上传图片</button>
                            <div class="layui-upload-list">
                                <img class="layui-upload-img" id="demo1" width="100px" height="100px" src="{$find.img}">
                                <input type="hidden" name="img" id="img" value="{$find.img}">
                                <p id="demoText"></p>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">排序：</label>
                    <div class="col-sm-4">
                        <input name="sort" value="{$find.sort}" class="form-control" type="text" >
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-block">
                        <input type="radio" name="is_shwo" value="1" title="开" checked="">显示
                        <input type="radio" name="is_shwo" value="2" title="关">隐藏
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-4 col-sm-offset-3">
                        <input type="hidden" name="id" value="{$find.id}">
                        <button class="btn btn-primary" type="submit">提交</button>
                        <button class="btn btn-default historygo" type="button">返回</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script>
    var ue = UE.getEditor('editor_id',{});
    layui.use(['upload', 'element','jquery', 'layer',  'laydate'], function(){
        var laydate = layui.laydate;
        var $ = layui.jquery
            ,upload = layui.upload
            ,element = layui.element
            ,layer = layui.layer;
        //常规使用 - 普通图片上传
        var uploadInst = upload.render({
            elem: '#test2'
            ,url: "{:url('Classification/upload')}" //改成 自己的上传接口
            ,before: function(obj){
                //预读本地文件示例
                obj.preview(function(index, file, result){
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
            }
            ,done: function(res){
                // console.log(res);
                //如果上传失败
                if(res.code == 0){
                    return layer.msg('上传失败');
                }
                if(res.code == 1){
                    $('#img').val(res.data);
                    return layer.msg('上传成功');
                }
                //上传成功的一些操作
                //……
                $('#demoText').html(''); //置空上传失败的状态
            }
            ,error: function(){
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
        });
    });
    layui.use('laydate', function() {
        var laydate = layui.laydate;

        //常规用法
        laydate.render({
            elem: '#test1'
        });
    })
</script>

{/block}